package com.ws.boot.demo.validate.service.method.parameter.impl;

import com.ws.boot.demo.validate.entity.IdCard;
import com.ws.boot.demo.validate.entity.Person;
import com.ws.boot.demo.validate.entity.Person4;
import com.ws.boot.demo.validate.service.method.parameter.MethodParameterForCheckerCollectionService;
import com.ws.boot.validate.annotation.constraint.Checker;
import com.ws.boot.web.domain.DefaultResponse;
import org.springframework.stereotype.Service;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Map;

/**
 * 方法参数 业务类 ： Checker 嵌套集合 实现类 .
 *
 * @className: MethodParameterForCheckerCollectionServiceImpl
 * @author: ws
 * @date: 2020/4/3 16:32
 * @version: 1.0.0
 */
@Service
public class MethodParameterForCheckerCollectionServiceImpl implements MethodParameterForCheckerCollectionService {

    /**
     * map 单层泛型 .
     *
     * @param map
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 14:20
     **/
    @Override
    public DefaultResponse map(@NotNull @Size(min = 2) Map<@NotBlank String, @Checker Person> map) {
        return DefaultResponse.success();
    }

    /**
     * list 单层泛型 .
     *
     * @param list
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/2 14:23
     **/
    @Override
    public DefaultResponse list(@NotNull @Size(min = 1, max = 3) List<@Checker IdCard> list) {
        return DefaultResponse.success();
    }

    /**
     * list 双层泛型 .
     *
     * @param list
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/14 13:50
     **/
    @Override
    public DefaultResponse list2Level(@NotEmpty List<@NotEmpty(message = "内部list不能为空") @Size(min = 2, message = "内部集合长度小于2") List<@NotBlank(message = "内部集合字符串不能为空") String>> list) {
        return DefaultResponse.success();
    }

    /**
     * map 双层泛型 .
     *
     * @param map
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/14 14:34
     **/
    @Override
    public DefaultResponse map2Level(@NotEmpty Map<String, @NotEmpty(message = "内部map不能为空") @Size(min = 3, message = "内部map大小至少3") Map<String, @NotBlank(message = "内部内部值不能为空") String>> map) {
        return DefaultResponse.success();
    }

    /**
     * list map 三层泛型嵌套 Checker .
     *
     * @param list
     * @return DefaultResponse
     * @author ws
     * @date 2020/4/14 15:10
     **/
    @Override
    public DefaultResponse listMapChecker3Level(@NotEmpty List<@Size(min = 1, max = 2) Map<@NotNull String, @NotEmpty @Size(min = 3) List<@Checker Person4>>> list) {
        return DefaultResponse.success();
    }
}
